/**
 * @Description: 基础画布抽象类
 * @author Beon
 * @date 2021/7/5
*/
import Container from './container';
import Widget from './widget';
import DropBox from './dropBox';
import {canPlant} from '../types/base';
import DropControl from '../utils/dropControl';

export default abstract class Plant implements canPlant{
	// 最外层
	static stopEl: HTMLElement
	// 绘制区id
	id: string
	// 绘制区域dom
	$el: HTMLElement
	// 内部内容框
	insideBox: Array<Container | Widget> = []
	// 可拖动方法
	dropControl: DropControl
	// 容器内部paddingTOP
	plantPaddingTop: number

	protected constructor(props: any) {
	    if (props.isStop) {
	        Plant.stopEl = props.element;
	    }
	    this.$el = props.element;
	    this.id = props.id;

	    this.$el.setAttribute('dropBox', props.id);
	    DropBox.setDropBox(this);
	    this.dropControl = new DropControl(props, this);
	    // TODO 不知道该放到哪里
	    this.plantPaddingTop = parseInt(window.getComputedStyle(this.$el).paddingTop);
	    this.$el.style.userSelect = 'none';
	}
}
